<?php

namespace App\Miya\Tools;

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;

class FalsifyCheckTool
{
    protected $refresh_ttl;

    public function __construct()
    {
        $this->refresh_ttl = config('allow.refresh_ttl');
    }

    public function check()
    {
        $cacheKey = 'falsify_check';
        if (Cache::has($cacheKey)) {
            return true;
        }
        $hash = md5(getFileContent(['../app', '../config', '../routes']));
        if ($hash == trim(Storage::get('hash.h'))) {
            Cache::add($cacheKey, true, $this->refresh_ttl);
            return true;
        } else {
            return false;
        }
    }
}
